package cn.terminus.data.customer.custombusinessinfo.impl;

import cn.terminus.common.customer.bean.custombusinessinfo.dto.*;
import cn.terminus.data.customer.custombusinessinfo.dao.CustomBusinessInfoDao;
import cn.terminus.data.customer.custombusinessinfo.mapper.CustomBusinessInfoMapper;
import cn.terminus.result.common.page.TerminusPageAble;
import cn.terminus.result.common.page.TerminusPageInfo;
import cn.terminus.result.common.util.BeanCopyUtils;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CustomBusinessInfo)表服务实现类
 *
 * @author makejava
 * @since 2021-07-08 11:18:36
 */
@Repository
public class CustomBusinessInfoDaoImpl implements CustomBusinessInfoDao {
    @Resource
    private CustomBusinessInfoMapper customBusinessInfoMapper;

    @Override
    public Integer add(CustomBusinessInfoNewDto dto) {
        return customBusinessInfoMapper.add(dto);
    }

    @Override
    public Integer update(CustomBusinessInfoNewDto dto) {
        return customBusinessInfoMapper.update(dto);
    }


    @Override
    public List<CustomBusinessInfoResultDto> query(CustomBusinessInfoQueryDto dto) {
        return customBusinessInfoMapper.query(dto);
    }

    @Override
    public Integer delete(CustomBusinessInfoDeleteDto dto) {
        return customBusinessInfoMapper.delete(dto);
    }

    @Override
    public TerminusPageAble<CustomBusinessInfoResultDto> page(CustomBusinessInfoQueryDto dto, TerminusPageInfo page) {
        PageHelper.startPage(page.getCurrentPage(), page.getPageSize());
        Page<CustomBusinessInfoResultDto> result = (Page<CustomBusinessInfoResultDto>) customBusinessInfoMapper.query(dto);
        return new TerminusPageAble<>(BeanCopyUtils.copy(result.getResult(), CustomBusinessInfoResultDto.class), page, result.getTotal());
    }

    @Override
    public Long getBussinessId(Long id) {
        return customBusinessInfoMapper.getBussinessId(id);
    }
}
